//
//  ATSixViewController.m
//  TAUi
//
//  Created by Lin Buken on 16/1/11.
//  Copyright © 2016年 com.aiton. All rights reserved.
//

#import "ATSixViewController.h"

@interface ATSixViewController ()

@end

@implementation ATSixViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    UIButton *bttn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    bttn1.frame = CGRectMake(50, 487, 20, 20);
    [bttn1 setImage:[UIImage imageNamed:@"radio_unchecked@2x"] forState:UIControlStateNormal];
    [bttn1 setImage:[UIImage imageNamed:@"radio_checked@2x"] forState:UIControlStateSelected];
    [bttn1 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [bttn1 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [bttn1 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *bttn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    bttn2.frame = CGRectMake(50, 526, 20, 20);
    [bttn2 setImage:[UIImage imageNamed:@"radio_unchecked@2x"] forState:UIControlStateNormal];
    [bttn2 setImage:[UIImage imageNamed:@"radio_checked@2x"] forState:UIControlStateSelected];
    [bttn2 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [bttn2 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [bttn2 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *bttn3 = [UIButton buttonWithType:UIButtonTypeCustom];
    bttn3.frame = CGRectMake(122, 487, 20, 20);
    [bttn3 setImage:[UIImage imageNamed:@"radio_unchecked@2x"] forState:UIControlStateNormal];
    [bttn3 setImage:[UIImage imageNamed:@"radio_checked@2x"] forState:UIControlStateSelected];
    [bttn3 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [bttn3 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [bttn3 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *bttn4 = [UIButton buttonWithType:UIButtonTypeCustom];
    bttn4.frame = CGRectMake(122, 526, 20, 20);
    [bttn4 setImage:[UIImage imageNamed:@"radio_unchecked@2x"] forState:UIControlStateNormal];
    [bttn4 setImage:[UIImage imageNamed:@"radio_checked@2x"] forState:UIControlStateSelected];
    [bttn4 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [bttn4 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [bttn4 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *bttn5 = [UIButton buttonWithType:UIButtonTypeCustom];
    bttn5.frame = CGRectMake(194, 487, 20, 20);
    [bttn5 setImage:[UIImage imageNamed:@"radio_unchecked@2x"] forState:UIControlStateNormal];
    [bttn5 setImage:[UIImage imageNamed:@"radio_checked@2x"] forState:UIControlStateSelected];
    [bttn5 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [bttn5 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [bttn5 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *bttn6 = [UIButton buttonWithType:UIButtonTypeCustom];
    bttn6.frame = CGRectMake(194, 526, 20, 20);
    [bttn6 setImage:[UIImage imageNamed:@"radio_unchecked@2x"] forState:UIControlStateNormal];
    [bttn6 setImage:[UIImage imageNamed:@"radio_checked@2x"] forState:UIControlStateSelected];
    [bttn6 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [bttn6 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [bttn6 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *bttn7 = [UIButton buttonWithType:UIButtonTypeCustom];
    bttn7.frame = CGRectMake(266, 487, 20, 20);
    [bttn7 setImage:[UIImage imageNamed:@"radio_unchecked@2x"] forState:UIControlStateNormal];
    [bttn7 setImage:[UIImage imageNamed:@"radio_checked@2x"] forState:UIControlStateSelected];
    [bttn7 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [bttn7 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [bttn7 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *bttn8 = [UIButton buttonWithType:UIButtonTypeCustom];
    bttn8.frame = CGRectMake(266, 526, 20, 20);
    [bttn8 setImage:[UIImage imageNamed:@"radio_unchecked@2x"] forState:UIControlStateNormal];
    [bttn8 setImage:[UIImage imageNamed:@"radio_checked@2x"] forState:UIControlStateSelected];
    [bttn8 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [bttn8 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [bttn8 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    [self.view addSubview:bttn1];
    [self.view addSubview:bttn2];
    [self.view addSubview:bttn3];
    [self.view addSubview:bttn4];
    [self.view addSubview:bttn5];
    [self.view addSubview:bttn6];
    [self.view addSubview:bttn7];
    [self.view addSubview:bttn8];

    
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn1.frame = CGRectMake(50, 604, 20, 20);
    [btn1 setImage:[UIImage imageNamed:@"address_unchecked_ico"] forState:UIControlStateNormal];
    [btn1 setImage:[UIImage imageNamed:@"address_checked_ico"] forState:UIControlStateSelected];
    [btn1 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [btn1 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [btn1 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn2.frame = CGRectMake(110, 604, 20, 20);
    [btn2 setImage:[UIImage imageNamed:@"address_unchecked_ico"] forState:UIControlStateNormal];
    [btn2 setImage:[UIImage imageNamed:@"address_checked_ico"] forState:UIControlStateSelected];
    //    添加点击事件
    [btn2 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [btn2 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [btn2 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn3.frame = CGRectMake(170, 604, 20, 20);
    [btn3 setImage:[UIImage imageNamed:@"address_unchecked_ico"] forState:UIControlStateNormal];
    [btn3 setImage:[UIImage imageNamed:@"address_checked_ico"] forState:UIControlStateSelected];
    [btn3 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [btn3 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [btn3 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *btn4 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn4.frame = CGRectMake(230, 604, 20, 20);
    [btn4 setImage:[UIImage imageNamed:@"address_unchecked_ico"] forState:UIControlStateNormal];
    [btn4 setImage:[UIImage imageNamed:@"address_checked_ico"] forState:UIControlStateSelected];
    [btn4 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [btn4 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [btn4 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    UIButton *btn5 = [UIButton buttonWithType:UIButtonTypeCustom];
    btn5.frame = CGRectMake(290, 604, 20, 20);
    [btn5 setImage:[UIImage imageNamed:@"address_unchecked_ico"] forState:UIControlStateNormal];
    [btn5 setImage:[UIImage imageNamed:@"address_checked_ico"] forState:UIControlStateSelected];
    [btn5 addTarget:self action:@selector(touchAction:) forControlEvents:UIControlEventTouchUpInside];
    [btn5 addTarget:self action:@selector(downAction) forControlEvents:UIControlEventTouchDown];
    [btn5 addTarget:self action:@selector(dragInside) forControlEvents:UIControlEventTouchDragInside];
    
    [self.view addSubview:btn1];
    [self.view addSubview:btn2];
    [self.view addSubview:btn3];
    [self.view addSubview:btn4];
    [self.view addSubview:btn5];
}


- (void)touchAction:(UIButton *)sender
{
    NSLog(@"TouchUpInside");
    if (sender.selected == NO) {
        sender.selected = YES;
    }else
    {
        sender.selected = NO;
    }
    
}
- (void)downAction
{
    NSLog(@"downAction");
}
- (void)dragInside
{
    NSLog(@"dragInside");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)btnSave:(id)sender {
    
    _labShow.text = @"该功能有待完善";
    
    // 创建 UIActivityIndicatorView 的对象
    UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(50, 523, 100, 100)];
    //    设置加载风格
    activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
    activityView.hidesWhenStopped = YES; // 停止时，是否隐藏
    
    //    设置加载的颜色
    activityView.color = [UIColor orangeColor];
    
    [activityView startAnimating];// 开始动画
    [self.view addSubview:activityView];
    
    //    状态栏的加载提示
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    
    [NSTimer scheduledTimerWithTimeInterval:5.0
                                     target:self
                                   selector:@selector(timerAction:)
                                   userInfo:activityView
                                    repeats:NO];
    
    
}

- (void)timerAction:(NSTimer *)timer
{
    UIActivityIndicatorView *actView = timer.userInfo;
    if (actView.isAnimating) { //是否在动画
        [actView stopAnimating]; //停止动画
    }
    
    //    状态栏 停止加载界面
    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
    
}

@end
